home *** CD-ROM | disk | FTP | other *** search
- #! /bin/csh -f
- #
- # findlogins This script will scan /usr/adm/SYSLOG for every entry
- # that is entered by 'login'. It will keep track of
- # each different user and count the number of times each
- # has logged in.
- #
- # Synopsis:
- # findlogins [<file>]
- #
- # Where:
- # <file> Optionally specifies the file to scan.
- #-----------------------------------------------------------------------
-
- if ( "$1" == "" ) then
- grep login /usr/adm/SYSLOG >/usr/tmp/logins
- echo "END" >>/usr/tmp/logins
- $0 recurs1 </usr/tmp/logins
- rm /usr/tmp/logins
- else if ( "$1" == "recurs1" ) then
- set users = ( )
- set counts = ( )
- set ases = ( )
-
- if ( -e ~/logins/.lasttime ) set do_time
-
- echo `date`
- set noglob
- while ( 1 )
- set line = $<
- if ( "$line" == "END" ) break
-
- set words = ( $line )
-
- if ( $?do_time ) then
- set time1 = "$words[1-3]"
- set time2 = "`gettime -m ~/logins/.lasttime '+%B %e %T'`"
- endif
-
- set name = $words[6]
- if ( "$name" == "failed:" ) then
- echo $words[6-]
- continue
- endif
- if ( "$words[7]" == "as" ) then
- set as = $words[8]
- else
- set as = SELF
- endif
- @ pos = 1
- foreach user ( $users )
- if ( "$user" == "$name" ) then
- if ( "$ases[$pos]" == "$as" ) then
- @ cnt = $counts[$pos] + 1
- set counts[$pos] = $cnt
- break
- endif
- endif
- @ pos = $pos + 1
- end
-
- if ( $#users < $pos ) then
- set users = ( $users $name )
- set counts = ( $counts 1 )
- set ases = ( $ases $as )
- endif
- end
-
- @ pos = 0
- foreach user ( $users )
- @ pos = $pos + 1
- echo "$user as $ases[$pos] logged in $counts[$pos] times"
- end
- echo
- else
- grep login $1 >/usr/tmp/logins
- echo "END" >>/usr/tmp/logins
- $0 recurs1 </usr/tmp/logins
- rm /usr/tmp/logins
- endif
-